/**
 *
 * jcrt and its source-code is licensed under the LGPL.
 * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
 * When copying, adapting, or redistributing this document in keeping with the guidelines above,
 * you are required to provide proper attribution to obinary.
 * If you reproduce or distribute the document without making any substantive modifications to its content,
 * please use the following attribution line:
 *
 * Copyright 2007 Atjava.com Ltd. (http://www.atjava.com) All rights reserved.
 *
 */
package com.atjava.jcrt.core.transaction;

import java.util.List;
import java.util.Map;

/**
 * Xml JcrtInfo Class
 * 
 * @author biggie
 * @version $Revision: 1.1 $ $Date: 2008/07/02 02:11:03 $
 */
public class XmlJcrtInfo implements java.io.Serializable{

	private static final long serialVersionUID = 1L;

	private String repositoryname = null;
	private String repositoryprovider = null;
	private String repositoryloadOnStartup = null;
	private Map<String,String> repositoryparams = null;
	private String repusername = null;
	private String reppassword = null;
	
	private List<String> workspaces = null;
	private Map<String, List<String[]>> namespaces = null;
	private List<XmlJcrtInfoDetail> repositoryMapping = null;
	public String getRepositoryloadOnStartup() {
		return repositoryloadOnStartup;
	}
	public void setRepositoryloadOnStartup(String repositoryloadOnStartup) {
		this.repositoryloadOnStartup = repositoryloadOnStartup;
	}
	public List getRepositoryMapping() {
		return repositoryMapping;
	}
	public void setRepositoryMapping(List<XmlJcrtInfoDetail> repositoryMapping) {
		this.repositoryMapping = repositoryMapping;
	}
	public String getRepositoryname() {
		return repositoryname;
	}
	public void setRepositoryname(String repositoryname) {
		this.repositoryname = repositoryname;
	}
	public Map getRepositoryparams() {
		return repositoryparams;
	}
	public void setRepositoryparams(Map<String,String> repositoryparams) {
		this.repositoryparams = repositoryparams;
	}
	public String getRepositoryprovider() {
		return repositoryprovider;
	}
	public void setRepositoryprovider(String repositoryprovider) {
		this.repositoryprovider = repositoryprovider;
	}
	public List getWorkspaces() {
		return workspaces;
	}
	public void setWorkspaces(List<String> workspaces) {
		this.workspaces = workspaces;
	}
	public Map getNamespaces() {
		return namespaces;
	}
	public void setNamespaces(Map<String, List<String[]>> namespaces) {
		this.namespaces = namespaces;
	}
	public String getReppassword() {
		return reppassword;
	}
	public void setReppassword(String reppassword) {
		this.reppassword = reppassword;
	}
	public String getRepusername() {
		return repusername;
	}
	public void setRepusername(String repusername) {
		this.repusername = repusername;
	}
	public XmlJcrtInfoDetail getXmlJcrtInfoDetail(Class theClass) throws XmlTransactionException{
		if (this.repositoryMapping == null || this.repositoryMapping.size() == 0)
			throw new XmlTransactionException("Unable to read xml config data for "+theClass.getName());
		
		for(int i=0;i<this.repositoryMapping.size();i++){
			XmlJcrtInfoDetail info = (XmlJcrtInfoDetail)this.repositoryMapping.get(i);
			if(info.getClassname().equals(theClass.getName())){
				return info;
			}
		}
		throw new XmlTransactionException("Unable to read xml config data for "+theClass.getName());
	}
}
